<div class="dropdown h-100 mr-2">
  <button class="btn btn-light h-100" type="button" data-toggle="dropdown" data-display="static" data-flip="false" aria-expanded="false">
    <span class="text-muted font-weight-normal"><%= Spree.t(:show) %>:</span>
    <% if product_filter_status_dropdown_value == Spree.t('admin.products.all_statuses') && product_filter_stock_dropdown_value == Spree.t('admin.products.any_stock') %>
      <%= Spree.t(:all_products) %>
    <% else %>
      <%= product_filter_status_dropdown_value if product_filter_status_dropdown_value != Spree.t('admin.products.all_statuses') %>
      <% if product_filter_status_dropdown_value != Spree.t('admin.products.all_statuses') && product_filter_stock_dropdown_value != Spree.t('admin.products.any_stock') %>
        and
      <% end %>
      <%= product_filter_stock_dropdown_value if product_filter_stock_dropdown_value != Spree.t('admin.products.any_stock') %>
    <% end %>
    <%= icon('chevron-down', class: 'arrow ml-1 mr-0') %>
  </button>
  <div class="dropdown-menu w-100" style="min-width: 200px">
    <h6 class="dropdown-header"><%= Spree.t('admin.products.by_status') %>:</h6>

    <%= active_link_to Spree.t('admin.products.all_statuses'), params.to_unsafe_h.deep_merge({page: nil, q: {status_eq: nil}}), class: 'dropdown-item', active: (params[:q] || {}).values_at(*%w[status_eq in_stock_items out_of_stock_items] ).all?(&:blank?) %>
    <%= link_to Spree.t('admin.products.active'),
      params.to_unsafe_h.deep_merge({page: nil, q: {status_eq: :active}}),
      class: "dropdown-item #{'active' if params[:q][:status_eq] == 'active'}" %>
    <%= link_to Spree.t('admin.products.draft'),
      params.to_unsafe_h.deep_merge({page: nil, q: {status_eq: :draft}}),
      class: "dropdown-item #{'active' if params[:q][:status_eq] == 'draft'}" %>
    <%= link_to Spree.t('admin.products.archived'),
      params.to_unsafe_h.deep_merge({page: nil, q: {status_eq: :archived}}),
      class: "dropdown-item #{'active' if params[:q][:status_eq] == 'archived'}" %>

    <div class="dropdown-divider"></div>

    <h6 class="dropdown-header"><%= Spree.t('admin.products.by_stock') %>:</h6>

    <%= active_link_to Spree.t('admin.products.any_stock'), params.to_unsafe_h.deep_merge({page: nil, q: {in_stock_items: nil, out_of_stock_items: nil}}), class: 'dropdown-item', active: (params[:q] || {}).values_at(*%w[status_eq in_stock_items out_of_stock_items] ).all?(&:blank?) %>
  </div>
</div>
